﻿using System;
using System.Windows.Data;
using System.Windows.Markup;
namespace TciNewsReader_2014_04.Converters
{
    /// <summary>
    /// Put a piece of text in parentheses for display
    /// </summary>
    public sealed class Parenthesizer : MarkupExtension, IValueConverter
    {
        public Parenthesizer(){}
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                return String.Format("({0})", value);
            }
            return null;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
}
